package com.demo.reservation.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.demo.reservation.domain.Reservation;
import com.demo.reservation.dto.CreateReservation;
import com.demo.reservation.dto.ReservationQueryParam;
import com.demo.reservation.service.ReservationService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/reservation")
public class ReservationController {
    @Resource
    private ReservationService reservationService;

    @PostMapping("/search")
    public IPage<Reservation> query(@RequestBody ReservationQueryParam params) {
        final IPage<Reservation> reservationIPage = reservationService.search(params);
        return reservationIPage;
    }

    @PostMapping("/create")
    public Reservation create(@RequestBody CreateReservation createReservation){
        return reservationService.create(createReservation);
    }
}
